<!DOCTYPE html>
<!-- 
Template Name: Metronic - Responsive Admin Dashboard Template build with Twitter Bootstrap 3.0
Version: 1.5
Author: KeenThemes
Website: http://www.keenthemes.com/
Purchase: http://themeforest.net/item/metronic-responsive-admin-dashboard-template/4021469?ref=keenthemes
-->
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
   <meta charset="utf-8" />
   <title>药店进销存管理系统 | 消费收银</title>
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <meta content="width=device-width, initial-scale=1.0" name="viewport" />
   <meta content="" name="description" />
   <meta content="" name="author" />
   <meta name="MobileOptimized" content="320">
   <!-- BEGIN GLOBAL MANDATORY STYLES -->          
   <link href="${base}/assets/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"/>
   <link href="${base}/assets/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
   <link href="${base}/assets/plugins/uniform/css/uniform.default.css" rel="stylesheet" type="text/css"/>
   <!-- END GLOBAL MANDATORY STYLES -->
   <!-- BEGIN PAGE LEVEL STYLES -->
   <link rel="stylesheet" type="text/css" href="${base}/assets/plugins/select2/select2_metro.css" />
   <link rel="stylesheet" href="${base}/assets/plugins/data-tables/DT_bootstrap.css" />
   <link rel="stylesheet" type="text/css" href="${base}/assets/plugins/fuelux/css/tree-metronic.css" />
   <!-- END PAGE LEVEL STYLES -->
   <!-- BEGIN THEME STYLES --> 
   <link rel="stylesheet" type="text/css" href="${base}/assets/plugins/bootstrap-datepicker/css/datepicker.css" />
   <link href="${base}/assets/css/style-metronic.css" rel="stylesheet" type="text/css"/>
   <link href="${base}/assets/css/style.css" rel="stylesheet" type="text/css"/>
   <link href="${base}/assets/css/style-responsive.css" rel="stylesheet" type="text/css"/>
   <link href="${base}/assets/css/plugins.css" rel="stylesheet" type="text/css"/>
   <link href="${base}/assets/css/themes/default.css" rel="stylesheet" type="text/css" id="style_color"/>
   <link href="${base}/assets/css/custom.css" rel="stylesheet" type="text/css"/>
   <!-- END THEME STYLES -->
   <link rel="shortcut icon" href="${base}/assets/img/favicon.ico" />
</head>
<!-- END HEAD -->
<!-- BEGIN BODY -->
<body class="page-header-fixed">
   <#include "header.ftl">
   <div class="clearfix"></div>
   <!-- BEGIN CONTAINER -->
   <div class="page-container">
      <!-- BEGIN SIDEBAR -->
      <div class="page-sidebar navbar-collapse collapse">
         <!-- BEGIN SIDEBAR MENU -->        
         <ul class="page-sidebar-menu">
            <li>
               <!-- BEGIN SIDEBAR TOGGLER BUTTON -->
               <div class="sidebar-toggler hidden-phone"></div>
               <!-- BEGIN SIDEBAR TOGGLER BUTTON -->
            </li>
            <li class="start">
		       <a href="${base}/admin/admin!main.action">
		       <i class="icon-home"></i> 
		       <span class="title">首页</span>
		       </a>
		    </li>
		    <li class="active">
		       <a href="javascript:;">
		       <i class="icon-cogs"></i> 
		       <span class="title">业务中心</span>
		       <span class="selected "></span>
		       </a>
		       <ul class="sub-menu">
		          <li class = "active">
		             <a href="${base}/admin/admin!cashiering.action">消费收银</a>
		          </li>
		       </ul>
		    </li>
		    <li>
		       <a href="javascript:;">
		       <i class="icon-bookmark-empty"></i> 
		       <span class="title">会员管理</span>
		       <span class="arrow "></span>
		       </a>
		       <ul class="sub-menu">
		          <li >
		             <a href="${base}/admin/member!checkin.action">会员登记</a>
		          </li>
		          <li >
		             <a href="#memberInfo" data-toggle="modal">会员信息</a>
		          </li>
		          <li >
		             <a href="${base}/admin/member!memberLevel.action">会员级别</a>
		          </li>
		          <li>
		             <a href="${base}/admin/member!memberList.action">会员列表</a>
		          </li>
		       </ul>
		    </li>
		    <li class="">
		       <a href="javascript:;">
		       <i class="icon-table"></i> 
		       <span class="title">库存管理</span>
		       <span class="arrow "></span>
		       </a>
		       <ul class="sub-menu">
		          <li >
		             <a href="${base}/admin/admin!purchase.action">采购进货</a>
		          </li>
		          <li >
		             <a href="${base}/admin/admin!refund.action">退货换货</a>
		          </li>
		          <li >
		             <a href="${base}/admin/inventory!list.action">库存盘点</a>
		          </li>
		       </ul>
		    </li>
		    <li class="">
		       <a href="javascript:;">
		       <i class="icon-sitemap"></i> 
		       <span class="title">供应商管理</span>
		       <span class="arrow "></span>
		       </a>
		       <ul class="sub-menu">
		          <li >
		             <a href="${base}/admin/supplier!add.action">供应商录入</a>
		          </li>
		          <li >
		             <a href="${base}/admin/supplier!list.action">供应商列表</a>
		          </li>
		       </ul>
		    </li>
		    <li class="">
		       <a href="javascript:;">
		       <i class="icon-gift"></i> 
		       <span class="title">药品管理</span>
		       <span class="arrow "></span>
		       </a>
		       <ul class="sub-menu">
		          <li >
		             <a href="${base}/admin/medicine!add.action">药品录入</a>
		          </li>
		          <li >
		             <a href="${base}/admin/medicine!list.action">药品列表</a>
		          </li>
		       </ul>
		    </li>
		    <li>
		       <a href="javascript:;">
		       <i class="icon-user"></i> 
		       <span class="title">用户管理</span>
		       <span class="arrow "></span>
		       </a>
		       <ul class="sub-menu">
		          <li >
		             <a href="${base}/admin/user!add.action">用户录入</a>
		          </li>
		          <li >
		             <a href="${base}/admin/user!list.action">用户列表</a>
		          </li>
		       </ul>
		    </li>
		    <li>
		       <a href="javascript:;">
		       <i class="icon-user"></i> 
		       <span class="title">单据管理</span>
		       <span class="arrow "></span>
		       </a>
		       <ul class="sub-menu">
		          <li>
		             <a href="${base}/admin/admin!sellerRecordList.action">消费单据</a>
		          </li>
		          <li >
		             <a href="${base}/admin/admin!purchaseList.action">采购单据</a>
		          </li>
		          <li >
		             <a href="${base}/admin/admin!refundList.action">退货单据</a>
		          </li>
		       </ul>
		    </li>
		    <!-- 会员信息弹出框开始 -->
		    <#include "memberInfoDialog.ftl">
		    <!-- 会员信息弹出框结束  -->
         </ul>
         <!-- END SIDEBAR MENU -->
      </div>
      <!-- END SIDEBAR -->
      <!-- BEGIN PAGE -->
      <div class="page-content">
      	 <#include "changePassword.ftl">
         <#include "system-set.ftl">
         <!-- 读卡操作开始-->               
         <div id="readCard" class="modal fade" role="dialog" aria-hidden="true" data-backdrop="static" >
		    <div class="modal-dialog">
		       <div class="modal-content">
		          <div class="modal-header">
		             <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
		             <h4 class="modal-title">读卡</h4>
		          </div>
		          <div class="modal-body">
		             <form action="#" class="form-horizontal">
		                <div class="form-group">
		                   <label class="control-label col-md-4">请输入卡号/手机号码</label>
		                   <div class="col-md-8">
		                      <input class="form-control" type="text" name = "cardNoOrTel" id = "cardNoOrTel"/>
		                   </div>
		                </div>
		                <div class="alert alert-danger display-hide" id = "CardNoNotExists">
		                  <button class="close" data-dismiss="alert"></button>
		                  	卡号或手机号码不存在
		               </div>
		             </form>
		          </div>
		          <div class="modal-footer">
		             <button class="btn green" onclick= "return doReadCard();">确定</button>
		             <button class="btn" data-dismiss="modal">取消</button>
		          </div>
		       </div>
		    </div>
		 </div>
         <!-- 读卡操作结束-->
         <!-- 结账操作开始-->
         	<div id="account" class="modal fade" role="dialog" aria-hidden="true" data-backdrop="static" >
		    <div class="modal-dialog">
		       <div class="modal-content">
		          <div class="modal-header">
		             <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
		             <h4 class="modal-title"><i class="icon-jpy"></i> 结账</h4>
		          </div>
		          <div class="modal-body">
		                     <form class="form-horizontal" role="form">
		                        <div class="form-body">
		                           <div class="form-group">
		                              <label  class="col-md-3 control-label">应付金额</label>
		                              <div class="col-md-9">
		                                 <input id = "yfje" type="text" style = "color:red;" value = "0.00" class="form-control" placeholder="应付金额" readonly>
		                              </div>
		                           </div>
		                           <div class="form-group">
		                              <label  class="col-md-3 control-label"></label>
		                              <div class="col-md-9">
		                                 <div class="checkbox-list">
		                                    <label>
		                                    	<input type="checkbox" id = "xjzf">
		                                    	<span> 现金支付：</span>
		                                    	<input id = "xjzfje" type="text" placeholder="现金支付" style = "width:60px;" > 元
		                                    </label>
		                                    <label>
		                                    	<input type="checkbox" id = "yhkzf">
		                                    	<span> 银行卡：</span>
		                                    	<input id = "yhkzfje" type="text" placeholder="银行卡" style = "margin-left:14px;width:60px;"> 元
		                                    	<input id = "yhkh" type="text" placeholder="请输入银行卡号" style = "width:160px;">
		                                    </label>
		                                    <label>
		                                    	<input type="checkbox" id = "qtzf">
		                                    	<span> 其他：</span>
		                                    	<input id = "qtzfje" type="text" placeholder="其他" style="margin-left:28px;width:60px;" > 元
		                                    </label>
		                                 </div>
		                              </div>
		                           </div>
		                           <div class="form-group">
		                              <label  class="col-md-3 control-label">找零</label>
		                              <div class="col-md-9">
		                                 <input type="text" class="form-control" style = "color:red;" value = "0.00" readonly>
		                              </div>
		                           </div>
		                        </div>
		                        <div class="form-group">
	                              <label  class="col-md-3 control-label">消费备注</label>
	                              <div class="col-md-8">
	                                 <input id = "bz" type="text" class="form-control" placeholder="消费备注">
	                              </div>
	                           </div>
		                        <div class="form-group">
	                              	<label  class="col-md-3 control-label">消费时间</label>
	                              	<div class="col-md-8">
					                    <input size="16" type="text" value="" readonly>
				                	</div>
	                           </div>
		                     </form>
		          </div>
		          <div class="modal-footer">
		             <button class="btn green" onclick= "return doCashiering();">确定</button>
		             <button class="btn" data-dismiss="modal">取消</button>
		          </div>
		       </div>
		    </div>
		 </div>
         <!-- 结账操作结束-->
         <!-- BEGIN PAGE HEADER-->
         <div class="row">
            <div class="col-md-12">
               <!-- BEGIN PAGE TITLE & BREADCRUMB-->
               <h5 class="page-title">
                  	消费收银 <small>这里进行收银员的收银操作，记录会员的消费信息</small>
               </h5>
               <ul class="page-breadcrumb breadcrumb">
                  <li>
                     <i class="icon-home"></i>
                     <a href="index.html">Home</a> 
                     <i class="icon-angle-right"></i>
                  </li>
                  <li>
                     <a href="#">业务中心</a>
                     <i class="icon-angle-right"></i>
                  </li>
                  <li><a href="#">消费收银</a></li>
               </ul>
               <!-- END PAGE TITLE & BREADCRUMB-->
            </div>
         </div>
         <!-- END PAGE HEADER-->
         <!-- BEGIN PAGE CONTENT-->
         <div class="row">
           <div class="col-md-5 responsive" data-tablet="col-md-12 fix-offset" data-desktop="col-md-4">
               <!--BEGIN EXAMPLE TABLE PORTLET-->
               <div class="portlet box blue">
                  <div class="portlet-title">
                     <div class="caption" style="font-size:12px;"><i class="icon-medkit"></i>药品列表</div>
                     <div class="actions">
                        <a onclick = "return appendToCart();" class="btn blue" style="font-size:12px;"><i class="icon-plus"></i> 添加到购物车</a>
                     </div>
                  </div>
                  <div class="portlet-body">
                     <table class="table table-striped table-bordered table-hover" id="medicineList">
                        <thead>
                           <tr>
                              <th style="width:8px;"><input type="checkbox" class="group-checkable" data-set="#medicineList .checkboxes" /></th>
                              <th style="font-size:12px;">编码</th>
                              <th style="font-size:12px;" class="hidden-480">名称</th>
                              <th style="font-size:12px;" class="hidden-480">单价</th>
                              <th style="font-size:12px;" class="hidden-480">库存</th>
                           </tr>
                        </thead>
                        <tbody>
                        	<#if medicineList?exists>
                        		<#list medicineList as medicine>
		                           <tr class="odd gradeX">
		                              <td><input type="checkbox" class="checkboxes" value="${medicine.id}" /></td>
		                              <td style="font-size:12px;">${medicine.no}</td>
		                              <td style="font-size:12px;">${medicine.name}</td>
		                              <td style="font-size:12px;">${medicine.retail_price}</td>
		                              <td style="font-size:12px;">${medicine.tempKc}</td>
		                           </tr>
                           		</#list>
                           </#if>
                        </tbody>
                     </table>
                  </div>
               </div>
               <!-- END EXAMPLE TABLE PORTLET-->
            </div>
        	<div class="col-md-7 responsive" data-tablet="col-md-12 fix-offset" data-desktop="col-md-6">
               <!-- BEGIN EXAMPLE TABLE PORTLET-->
               <div class="portlet box blue">
                  <div class="portlet-title">
                     <div class="caption" style="font-size:12px;"><i class="icon-shopping-cart"></i>购物车</div>
                     <div class="actions">
                        <a style="font-size:12px;" onclick = "clearOut();" class="btn blue"><i class="icon-trash"> 清空购物车 </i></a>
                     </div>
                  </div>
                  <div class="portlet-body">
                     <table class="table table-striped table-bordered table-hover" id="costInfo">
                        <thead>
                           <tr>
                           	  <th class="hidden-480">药品名称</th>
                              <th class="hidden-480">单价</th>
                              <th class="hidden-480">数量</th>
                              <th class="hidden-480">折扣系数</th>
                              <th class="hidden-480">折后金额</th>
                              <th class="hidden-480">操作</th>
                           </tr>
                        </thead>
                        <tbody>
                        </tbody>
                     </table>
                     <!-- 工具按钮开始 -->
                     <div class="portlet-title" style = "padding-top:50px;">
	                     <div class="actions">
	                     	<div>
		                     	<span>总数量:</span><span style = "color:red;" id = "totalAmount">  0 </span>
	                     	 	<span>总金额:</span><span style = "color:red;" id = "totalMoney">  0.00 </span>
                     	 	
		                        <a onclick = "return cashiering();" id = "goToCashiering" class="btn blue disabled" style = "padding:3px 6px;float:right;"><i class="icon-jpy"></i> 结账</a>
		                        <a onclick = "return readCard();" data-toggle="modal" class="btn green" style = "padding:3px 6px;float:right;margin-right:10px;"><i class="icon-hand-right"></i> 读卡</a>
	                        </div>
	                     </div>
	                  </div>
                     <!-- 工具按钮结束 -->
                     <!-- 会员信息开始 -->
                              <!-- BEGIN FORM-->
                              <form class="form-horizontal form-row-seperated" role="form">
                                 <div class="form-body">
                                    <h3 class="form-section" style = "text-align:center;">会员信息</h3>
                                    <div class="row">
                                       <div class="col-md-6">
                                          <div class="form-group">
                                             <label class="control-label col-md-4">会员卡号:</label>
                                             <div class="col-md-8">
                                                <p class="form-control-static" id = "cardno"></p>
                                             </div>
                                          </div>
                                       </div>
                                       <!--/span-->
                                       <div class="col-md-6">
                                          <div class="form-group">
                                             <label class="control-label col-md-4">会员姓名:</label>
                                             <div class="col-md-8">
                                                <p class="form-control-static" id = "name"></p>
                                             </div>
                                          </div>
                                       </div>
                                       <!--/span-->
                                    </div>
                                    <!--/row-->
                                    <div class="row">
                                       <div class="col-md-6">
                                          <div class="form-group">
                                             <label class="control-label col-md-4">会员级别:</label>
                                             <div class="col-md-8">
                                                <p class="form-control-static" id = "level"></p>
                                             </div>
                                          </div>
                                       </div>
                                       <!--/span-->
                                       <div class="col-md-6">
                                          <div class="form-group">
                                             <label class="control-label col-md-4">登记日期:</label>
                                             <div class="col-md-8">
                                                <p class="form-control-static" id = "joindate"></p>
                                             </div>
                                          </div>
                                       </div>
                                       <!--/span-->
                                    </div>
                                 </div>
                              </form>
                              <!-- END FORM-->
                     <!-- 会员信息结束 -->
                  </div>
               </div>
               <!-- END EXAMPLE TABLE PORTLET-->
            </div>
         </div>
         <!-- END PAGE CONTENT-->
      </div>
      <!-- END PAGE -->
   </div>
   <!-- END CONTAINER -->
   <!-- BEGIN FOOTER -->
   <div class="footer">
      <div class="footer-inner">
         2014 &copy; 西南财经大学天府学院  | 袁金廷
      </div>
      <div class="footer-tools">
         <span class="go-top">
         <i class="icon-angle-up"></i>
         </span>
      </div>
   </div>
   <!-- END FOOTER -->
   <!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->
   <!-- BEGIN CORE PLUGINS -->   
   <!--[if lt IE 9]>
   <script src="${base}/assets/plugins/respond.min.js"></script>
   <script src="${base}/assets/plugins/excanvas.min.js"></script> 
   <![endif]-->   
   <script src="${base}/assets/plugins/jquery-1.10.2.min.js" type="text/javascript"></script>
   <script src="${base}/assets/plugins/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>    
   <script src="${base}/assets/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
   <script src="${base}/assets/plugins/bootstrap-hover-dropdown/twitter-bootstrap-hover-dropdown.min.js" type="text/javascript" ></script>
   <script src="${base}/assets/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
   <script src="${base}/assets/plugins/jquery.blockui.min.js" type="text/javascript"></script>  
   <script src="${base}/assets/plugins/jquery.cookie.min.js" type="text/javascript"></script>
   <script src="${base}/assets/plugins/uniform/jquery.uniform.min.js" type="text/javascript" ></script>
   <!-- END CORE PLUGINS -->
   <!-- BEGIN PAGE LEVEL PLUGINS -->
   
   <script type="text/javascript" src="${base}/assets/plugins/select2/select2.min.js"></script>
   <script type="text/javascript" src="${base}/assets/plugins/data-tables/jquery.dataTables.js"></script>
   <script type="text/javascript" src="${base}/assets/plugins/data-tables/DT_bootstrap.js"></script>
   <script type="text/javascript" src="${base}/assets/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
   <script type="text/javascript" src="${base}/assets/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
   <!-- END PAGE LEVEL PLUGINS -->
   <!-- BEGIN PAGE LEVEL SCRIPTS -->
   <script src="${base}/assets/scripts/app.js"></script>
   <script src="${base}/resources/scripts/cashiering-managed.js"></script>
   <script>
      jQuery(document).ready(function() {       
         App.init();
         CashieringManaged.init();
         $("#xjzf").click(function(){
         	$("#xjzfje").val($("#yfje").val());
       	 });
         $("#yhkzf").click(function(){
         	$("#yhkzfje").val($("#yfje").val());
         });
         $("#qtzf").click(function(){
         	$("#qtzfje").val($("#yfje").val());
         });
      });
      
      /**
      	添加到购物车
      */
      function appendToCart(){
      	var flag = "false";
      	var idValue=""; //选中的药品id
      	var idCart="";//购物车中已经选择的药品id
      	var row = $("#costInfo tbody tr").length;//购物车中药品的行数
		$("#medicineList tbody :checkbox").each(function(i){
			if($(this).attr("checked")=="checked"){
				flag = "true";//设置标志为true，表示选中了至少一条数据
				var medicineId = $(this).val();//获得当前遍历的第一个数据的id
				/**
					如果购物车中没有数据，则直接添加到购物车中
				*/
				if(row <= 0){
					idValue = medicineId+","+idValue;//把选中的id,存放在字符串中.便于传递到后台
				}else{
					/**
						遍历购物车中的数据
					*/
					var f;
					$('#costInfo tbody tr').each(function (i) {
						f = "false";
						var id = $(this).find("#cartId").val();
						if(id == medicineId){
							f = "true";
							var amount = $(this).find("#amount").html();
							$(this).find("#amount").html(amount*1+1*1);
							$(this).find("#discountTotal").html($(this).find("#amount").html()*$(this).find("#price").html()*$(this).find("#discount").html());
							return false;
						}
			        });
			        setTotal();//设置总数量和总金额
			        if(f == "false"){
			        	idValue = medicineId+","+idValue;
			        }
				}
			}
		});
		
		if(idValue==""){
			return;
		}	
		if(flag=="false"){
			alert("没有选中可添加的药品到购物车!请选择药品!");
		}else{
			$.ajax({
	            type:"post",
	            url:"/pims/admin/medicine!compute.action",
	            dataType:"json",
	            data:"ids="+idValue+"&level="+$("#level").html()+"&idCart="+idCart,
	            cache:false,
	            beforeSend:function(XMLHttpRequest){
	            },
	            success:function(json){
	            	cart = json.cart;
	            	$(cart).each(function(i){
			            $( "#costInfo tbody" ).append( "<tr>" +
			              '<input type="hidden" id = "cartId" value = '+ cart[i].id + '>' +
			              '<input type="hidden" id = "cartNo" value = '+ cart[i].no + '>' +
			              '<td id = "commodityName">' + cart[i].commodityName + "</td>" +
			              '<td id = "price">' + cart[i].price + "</td>" +
			              '<td id = "amount" ondblclick="editMedicineNumber(this);">' + cart[i].amount + "</td>" +
			              '<td id = "discount">' + cart[i].discount + "</td>" +
			              '<td id = "discountTotal">' + cart[i].discountTotal +"</td>" +
			              '<td>'+'<a onclick = "trash();" class="btn default btn-xs black">'+'<i class="icon-trash">'+'</i>Delete</a></td>'+
			            "</tr>" );
			    	});
	            },
	           	complete:function(XMLHttpRequest,textStatus){
	           		setTotal();//设置总数量和总金额
	           		$("#goToCashiering").removeClass("disabled");
	           	},
	          	error:function(XMLHttpRequest,textStatus,errorThrown){
	                   alert("添加失败");
	          	}
            });
		}
      				
      }
      /**
      	清空购物车
      */
      function clearOut(){
      	$("#costInfo tbody tr").remove();
      	$("#goToCashiering").addClass("disabled");
      	$("#totalAmount").html(0);
		$("#totalMoney").html(0.00);
      }
      
      /**
      	弹出读卡窗口
      */
      function readCard(){
      	if($("#cardno").html()==""){
      			$('#readCard').modal('show');
      		}else{
      			if(confirm("提示!是否放弃当前消费?") == true){
      				$("#costInfo tbody tr").remove();
      				$("#goToCashiering").addClass("disabled");
      				$("#totalAmount").html(0);
					$("#totalMoney").html(0.00);
      				$('#readCard').modal('show');
      			}
      		}
      }
      
      /**
      	读卡操作
      */
      function doReadCard(){
      	var row = $("#costInfo tbody tr").length;
      	$.ajax({
            type:"post",
            url:"/pims/admin/member!validationCardnoOrTel.action",
            dataType:"json",
            data:"cardnoOrTel="+$("#cardNoOrTel").val(),
            cache:false,
            beforeSend:function(XMLHttpRequest){
            },
            success:function(json){
            	result = json.result;
            	if(result){
            		$("#cardno").html(json.cardno);
            		$("#name").html(json.name);
            		$("#level").html(json.level);
            		$("#joindate").html(json.joindate);
            		//如果购物车中存在数据，就更新每条数据的折扣和折后金额,并更新总金额
            		if(row<=0){}else{
            			$('#costInfo tbody tr').each(function (i) {
							var amount = $(this).find("#amount").html();
							$(this).find("#discount").html(json.discount);
							$(this).find("#discountTotal").html($(this).find("#amount").html()*$(this).find("#price").html()*$(this).find("#discount").html());
				        });
				        setTotal();
            		}
            		$('#readCard').modal('hide');
            	}else{
            		alert("卡号不存在");
            	}
            },
           	complete:function(XMLHttpRequest,textStatus){
           	},
          	error:function(XMLHttpRequest,textStatus,errorThrown){
                   alert("网络错误");
          	}
        });
        return false;
      }
      
      /**
      	弹出结账窗口
      */
      function cashiering(){
      		$("#yfje").val($("#totalMoney").html());
      		if($("#cardno").html()==""){
      			if(confirm("提示!还没有进行读卡操作,确定继续吗?") == true){
      				$('#account').modal('show');
      			}
      		}else{
      			$('#account').modal('show');
      		}
      }
      /**
      	结账操作
      */
      function doCashiering(){
      	var tableString = "";//定义一个字符串，存放表中所有数据
  		$('#costInfo tbody tr').each(function(ri){
  			var trString = "";//定义一个字符串，存放行中所有数据
  			$(this).each(function(di){
  				trString = $(this).find("#cartNo").val();
  				trString = trString + "," + $(this).find("#commodityName").html();
  				trString = trString + "," + $(this).find("#price").html();
				trString = trString + "," + $(this).find("#amount").html();
				trString = trString + "," + $(this).find("#discount").html();
				trString = trString + "," + $(this).find("#discountTotal").html();
			});
			tableString = trString + ";" + tableString;
        });
      	$.ajax({
            type:"post",
            url:"/pims/admin/admin!doCashiering.action",
            dataType:"json",
            data:"cart="+tableString+"&cardno="+$("#cardno").html()+"&yfje="+$("#yfje").val()+"&xjzfje="+$("#xjzfje").val()
            		+"&yhkzfje="+$("#yhkzfje").val()+"&qtzfje="+$("#qtzfje").val()+"&bz="+$("#bz").val()+$("#yhkh").val(),
            cache:false,
            beforeSend:function(XMLHttpRequest){
            },
            success:function(json){
            	result = json.result;
            	if(result){
            		alert("结账成功");
            		$('#account').modal('hide');
            		$("#costInfo tbody tr").remove();
      				$("#goToCashiering").addClass("disabled");
      				$("#totalAmount").html(0);
      				$("#totalMoney").html(0.00);
      				$("#joindate").html("");
      				$("#cardno").html("");
      				$("#name").html("");
      				$("#level").html("");
            	}else{
            		alert("操作失败");
            	}
            },
           	complete:function(XMLHttpRequest,textStatus){
           	},
          	error:function(XMLHttpRequest,textStatus,errorThrown){
                   alert("网络错误，请稍后重试");
          	}
        });
        return false;
      }
      /**
      	双击修改数量
      */
      function editMedicineNumbers(td) {
            var input = document.createElement("input");
            input.type = "text";
            input.style.width = "50px";
            var child = td.childNodes[0];
            if (child) {
                input.value = child.nodeValue;
                td.removeChild(child);
            }
            $(input).blur(function() {
                if (!isNaN(this.value) && vPositiveNum(this.value)) {
                    $(td).append(this.value);
                    td.removeChild(this);
                    //refreshConsume(td.parentNode);
                    //refreshStatisc();
                    td.isEditing = false;
                }
                else {
                    alert("数量输入有误，数量只能为正数!");
                    document.execCommand("undo");
                    this.focus();
                    this.select();
                }
            });
            td.appendChild(input);
            td.isEditing = true;
            input.select();
        }
    	/**
        	获取购物车的所有数据，设置总数量和总金额
        */
        function setTotal(){
	        var total_Amount = 0;//总数量
	        var total_Money = 0; //总金额
	        $('#costInfo tbody tr').each(function (i) {
				total_Amount = $(this).find("#amount").html()*1+total_Amount*1;
				total_Money = $(this).find("#discountTotal").html()*1+total_Money*1;
	        });
	        $("#totalAmount").html(total_Amount);
			$("#totalMoney").html(total_Money);
        }
        
        
   </script>
</body>
<!-- END BODY -->
</html>